@extends('public.father')
@section('title','用户文章列表页')
@section('content')
    <div class="container">
        <div class="jumbotron">
            @include('public._errors')
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>用户名</th>
                    <th>文章标题</th>
                    <th>发布时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($blogs as $blog)
                    <tr>
                        <td>{{$user->name}}</td>
                        <td scope="row">{{$blog->title}}</td>
                        <td>{{$blog->created_at}}</td>
                        <td>
                            <div class="btn-group">
                                @can('update',$user)
                                    <a href="{{route('blog.edit',$blog)}}" class="btn btn-success">编辑</a>
                                @endcan
                                @can('update',$user)
                                    <form action="{{route('blog.destroy',$blog)}}" method="post">
                                        @csrf
                                        @method('delete')
                                        <button type="submit" class="btn btn-danger">删除</button>
                                    </form>
                                @endcan
                            </div>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            {{ $blogs->links() }}

            <a href="javascript:window.history.back();" class="btn btn-primary">返回</a>
        </div>
    </div>
@endsection